#
# @lc app=leetcode.cn id=3185 lang=python3
#
# [3185] 构成整天的下标对数目 II
#

# @lc code=start
from collections import defaultdict
from typing import List


class Solution:
    def countCompleteDayPairs(self, hours: List[int]) -> int:
        ans = 0
        cnt = defaultdict(int)
        for i,x in enumerate(hours):
            tag = (24 - x%24)%24
            if tag in cnt:
                ans += cnt[tag]
            cnt[x%24] += 1
        return ans
# @lc code=end

